﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using SPDevLab.WebParts.JsAppWebPart.Apps;
using SPDevLab.WebParts.JsAppWebPart.Services.Base;

namespace SPDevLab.WebParts.Extensions
{
    public static class JsAppServiceBaseExtensions
    {
        #region methods

        public static AppPackage LoadLastActiveApp(this JsAppServiceBase jsAppService, SPSite site, string siteRelatedAppFolderUrl)
        {
            return jsAppService
                            .LoadApps(site, siteRelatedAppFolderUrl)
                            .OrderByDescending(a => a.Version).FirstOrDefault();
        }

        #endregion
    }
}
